<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

// 统计--玩家投注
use App\Console\Stats\PlayerBet\Job\Hour as StatsPlayerBetHourJob;
use App\Console\Stats\PlayerBet\Job\Day as StatsPlayerBetDayJob;
use App\Console\Stats\PlayerBet\Job\Month as StatsPlayerBetMonthJob;
use App\Console\Stats\PlayerBet\Task\Hour as StatsPlayerBetHourTask;
use App\Console\Stats\PlayerBet\Task\Day as StatsPlayerBetDayTask;
use App\Console\Stats\PlayerBet\Task\Month as StatsPlayerBetMonthTask;
use App\Console\Stats\PlayerBet\Bulk as StatsPlayerBetBulk;

// 统计--玩家统计
use App\Console\Stats\User\Job\Day as StatsUserDayJob;
use App\Console\Stats\User\Job\Week as StatsUserWeekJob;
use App\Console\Stats\User\Job\Month as StatsUserMonthJob;
use App\Console\Stats\User\Task\Day as StatsUserDayTask;
use App\Console\Stats\User\Task\Week as StatsUserWeekTask;
use App\Console\Stats\User\Task\Month as StatsUserMonthTask;
use App\Console\Stats\User\Bulk as StatsUserBulk;

// 统计--留存统计
use App\Console\Stats\Retention\Job\Day\Sign as StatsRetentionDaySignJob;
use App\Console\Stats\Retention\Job\Day\Game as StatsRetentionDayGameJob;
use App\Console\Stats\Retention\Task\Day\Sign as StatsRetentionDaySignTask;
use App\Console\Stats\Retention\Task\Day\Game as StatsRetentionDayGameTask;
use App\Console\Stats\Retention\Bulk as StatsRetentionBulk;

// 统计--平台收益
use App\Console\Stats\Platform\Settlement\Job\Day as StatsPlatformSettlementDayJob;
use App\Console\Stats\Platform\Settlement\Job\Month as StatsPlatformSettlementMonthJob;
use App\Console\Stats\Platform\Settlement\Task\Day as StatsPlatformSettlementDayTask;
use App\Console\Stats\Platform\Settlement\Task\Month as StatsPlatformSettlementMonthTask;
use App\Console\Stats\Platform\Settlement\Bulk as StatsPlatformSettlementBulk;

// 统计--结算统计
use App\Console\Stats\Settlement\Job\All as StatsSettlementAllJob;
use App\Console\Stats\Settlement\Job\Game as StatsSettlementGameJob;
use App\Console\Stats\Settlement\Job\GameScene as StatsSettlementGameSceneJob;
use App\Console\Stats\Settlement\Task\All as StatsSettlementAllTask;
use App\Console\Stats\Settlement\Task\Game as StatsSettlementGameTask;
use App\Console\Stats\Settlement\Task\GameScene as StatsSettlementGameSceneTask;
use App\Console\Stats\Settlement\Bulk as StatsSettlementBulk;

// 统计--游戏统计
use App\Console\Stats\Game\Job\Game as StatsGameGameJob;
use App\Console\Stats\Game\Task\Game as StatsGameGameTask;
use App\Console\Stats\Game\Bulk as StatsGameBulk;

// 工具--清理数据
use App\Console\Tools\Clean\UserLoginLog as ToolsCleanUserLoginLog;
use App\Console\Tools\Clean\Elasticsearch as ToolsCleanElasticsearch;

// 工具--导入数据
use App\Console\Tools\Import\WalletOrder;

class Kernel extends ConsoleKernel
{

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        // 统计--玩家投注
        StatsPlayerBetHourTask::class,
        StatsPlayerBetDayTask::class,
        StatsPlayerBetMonthTask::class,
        StatsPlayerBetHourJob::class,
        StatsPlayerBetDayJob::class,
        StatsPlayerBetMonthJob::class,
        StatsPlayerBetBulk::class,

        // 统计--玩家统计
        StatsUserDayJob::class,
        StatsUserWeekJob::class,
        StatsUserMonthJob::class,
        StatsUserDayTask::class,
        StatsUserWeekTask::class,
        StatsUserMonthTask::class,
        StatsUserBulk::class,

        // 统计--留存统计
        StatsRetentionDaySignJob::class,
        StatsRetentionDayGameJob::class,
        StatsRetentionDaySignTask::class,
        StatsRetentionDayGameTask::class,
        StatsRetentionBulk::class,

        // 统计--平台收益
        StatsPlatformSettlementDayTask::class,
        StatsPlatformSettlementMonthTask::class,
        StatsPlatformSettlementDayJob::class,
        StatsPlatformSettlementMonthJob::class,
        StatsPlatformSettlementBulk::class,
        // 统计--结算统计
        StatsSettlementAllJob::class,
        StatsSettlementGameJob::class,
        StatsSettlementGameSceneJob::class,
        StatsSettlementAllTask::class,
        StatsSettlementGameTask::class,
        StatsSettlementGameSceneTask::class,
        StatsSettlementBulk::class,
        // 统计--游戏统计
        StatsGameGameJob::class,
        StatsGameGameTask::class,
        StatsGameBulk::class,
        // 工具--清理数据
        ToolsCleanUserLoginLog::class,
        ToolsCleanElasticsearch::class,
        // 工具--导入数据
        WalletOrder::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        /**
         * ************************ 玩家投注【小时/天/月】 *************************
         */
        // 创建统计任务，并发布到队列【每小时的第 5/25 分钟执行一次任务】
        $schedule->command(StatsPlayerBetBulk::class)->hourlyAt([5, 25])->runInBackground();

        /**
         * ************************ 平台收益【天】 *************************
         */
        // 创建统计任务，并发布到队列【每天1:00至4:00】【每小时的第 1 分钟执行一次任务】
        $schedule->command(StatsPlatformSettlementBulk::class)->hourlyAt(1)->between('1:00', '4:00')->runInBackground();

        /**
         * ************************ 结算统计【天】 *************************
         */
        // 创建统计任务，并发布到队列【每天1:00至4:00】【每小时的第 3 分钟执行一次任务】
        $schedule->command(StatsSettlementBulk::class)->hourlyAt(3)->between('1:00', '4:00')->runInBackground();

        /**
         * ************************ 游戏统计【天】 *************************
         */
        // 创建统计任务，并发布到队列【每天1:00至4:00】【每小时的第 5 分钟执行一次任务】
        $schedule->command(StatsGameBulk::class)->hourlyAt(5)->between('1:00', '4:00')->runInBackground();

        /**
         * ************************ 留存统计【天】 *************************
         */
        // 创建统计任务，并发布到队列【每天1:00至4:00】【每小时的第 7 分钟执行一次任务】
        $schedule->command(StatsRetentionBulk::class)->hourlyAt(7)->between('1:00', '4:00')->runInBackground();

        /**
         * ************************ 玩家统计【天/周/月】 *************************
         */
        // 创建统计任务，并发布到队列【每天1:00至4:00】【每小时的第 9 分钟执行一次任务】
        $schedule->command(StatsUserBulk::class)->hourlyAt(9)->between('1:00', '4:00')->runInBackground();

        /**
         * ************************ 清理日志 *************************
         */
        // 清理活动日志，保留最近 60 天记录【每天 0 点执行一次任务】
        $schedule->command('activitylog:clean --days=60')->daily()->runInBackground();
        // 清理登录日志，保留最近 60 天记录【每天 0 点执行一次任务】
        $schedule->command('tools:clean:user-login-log --days=60')->daily()->runInBackground();
        // 清理 ES 日志，保留最近 90 天记录【每天 0 点执行一次任务】
        $schedule->command('tools:clean:es --days=90')->daily()->runInBackground();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        // $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
